import request from '@/utils/request';
import { TenantQuery, TenantForm, TenantPermission } from './types';

/**
 * 获取租户列表
 */
export function listTenant(data: TenantQuery) {
  return request({
    url: '/api/sys/tenant/list',
    method: 'post',
    data
  });
}

/**
 * 添加租户
 *
 * @param data
 */
export function addTenant(data: TenantForm) {
  return request({
    url: '/api/sys/tenant/add',
    method: 'post',
    data
  });
}

/**
 * 修改租户
 *
 * @param id
 * @param data
 */
export function updateTenant(data: TenantForm) {
  return request({
    url: '/api/sys/tenant/update',
    method: 'post',
    data
  });
}

/**
 * 批量删除租户
 *
 * @param ids 菜单ID []
 */
export function deleteListTenant(ids: number[]) {
  return request({
    url: '/api/sys/tenant/delete/batch',
    method: 'post',
    data: { ids }
  });
}


/**
 * 分配菜单权限给租户
 *
 * @param data
 */
export function updateTenantMenus(
  data: any
) {
  return request({
    url: '/api/sys/tenant/menu/update',
    method: 'post',
    data: data
  });
}

/**
 * 获取租户权限
 *
 * @param data
 */
export function tenantPermissionList(data: TenantPermission) {
  return request({
    url: '/api/sys/tenant/menu/query',
    method: 'post',
    data
  });
}